{% extends "base.html" %}
{% load getattribute %}
{% block extrajs %}
<script type="text/javascript" charset="utf-8">
  dojo.addOnLoad(function(){
    dojo.connect(dijit.byId('id_gateway'),'onChange',function(event){
      if(!dijit.byId('id_dns1').value)
        dijit.byId('id_dns1').set('value',dijit.byId('id_gateway').value);
    });
    dojo.connect(dijit.byId('id_serial'),'onChange',function(event){
      if(!dijit.byId('id_hostname').value)
        dijit.byId('id_hostname').set('value','fai-'+dijit.byId('id_serial').value);
    });

  })
</script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/DijitRelatedObjectLookups.js"></script>
    <style type="text/css">
        #id_commentaire{
            width:90%! important;
        }
    </style>
{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
<table class="clariadmin_form">
  {% if form.non_field_errors %}
    <tr><td colspan="99">{{ form.non_field_errors }}</td></tr>
  {% endif %}
  {% for field in form %}
    {% if not field.name == "commentaire" %}
  <tr>
    <th>{{field.label}}</th>
    <td>{{field}}</td><td>
      {% if field.name in foreign %}
        {% with data=foreign|getattribute:field.name %}
          {% if data.perm  %}
          <a id='add_id_{{field.name}}' class="add-another" href="/admin/{{ data.address }}/add" onclick="return showAddAnotherPopup(this);">
          <img width="10" height="10" alt="Ajouter un autre" src="/adm_media/img/admin/icon_addlink.gif" />
          </a>
    {% endif %}{% endwith %}{% endif %}</td>
   <td>{{field.errors}}</td>
  </tr>
    {% endif %}
  {% endfor %}
</table>
{% if form.commentaire %}
  <table style="width:99%!important;" class="clariadmin_form better">
    <tr>
        <th>{{ form.commentaire.label_tag }}:</th>
        <td>{{ form.commentaire }}</td>
        {% if form.commentaire.errors %}<td>{{ form.commentaire.errors }}</td>{% endif %}
    </tr>
</table>
{% endif %}

<div id="save_buttons">
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconDelete" type="submit" name="submit_button" value="delete">Suprimer</button>
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconUndo" type="button" onclick='window.location=".."'>Aller à la liste</button>
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconSave" type="submit" name="submit_button" value="save">Enregistrer</button>
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconNewPage" type="submit" name="submit_button" value="new">Enregistrer et ajouter un nouveau</button>
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconRightToLeft" type="submit" name="submit_button" value="return">Enregistrer et retourner à la liste</button>
</div>
</form>
{% endblock %}
